using System;
using NUnit.Framework;

namespace ValidationFramework.Tests
{
  [TestFixture]
  public class RequiredDateTimeRuleAttributeTest
  {
    [Test]
    public void CheckDefaultValues()
    {
      var ruleAttribute = new RequiredDateTimeRuleAttribute();
      Assert.AreEqual(null, ruleAttribute.InitialValue);
      
		var propertyRule = (RequiredRule<DateTime>)ruleAttribute.CreateInstance(new MockPropertyDescriptor<DateTime>("foo"));
      var parameterRule = (RequiredRule<DateTime>)ruleAttribute.CreateInstance(new MockParameterDescriptor<DateTime>("foo"));
      var fieldRule = (RequiredRule<DateTime>)ruleAttribute.CreateInstance(new MockFieldDescriptor<DateTime>("foo"));

    }

    [Test]
    public void CheckNonDefaultValues()
    {
      var ruleAttribute = new RequiredDateTimeRuleAttribute();
      const string expectedInitialValueString = "01 Jan 2006";
      var  expectedInitialValueDateTime = new DateTime(2006,1,1);
      ruleAttribute.InitialValue = expectedInitialValueString;
      Assert.AreEqual(expectedInitialValueString, ruleAttribute.InitialValue);

      var propertyRule = (RequiredRule<DateTime>)ruleAttribute.CreateInstance(new MockPropertyDescriptor<DateTime>("foo"));
      var parameterRule = (RequiredRule<DateTime>)ruleAttribute.CreateInstance(new MockParameterDescriptor<DateTime>("foo"));
      var fieldRule = (RequiredRule<DateTime>)ruleAttribute.CreateInstance(new MockFieldDescriptor<DateTime>("foo"));

      Assert.AreEqual(expectedInitialValueDateTime, propertyRule.InitialValue);

      Assert.AreEqual(expectedInitialValueDateTime, parameterRule.InitialValue);

	  Assert.AreEqual(expectedInitialValueDateTime, fieldRule.InitialValue);
    }


      [Test]
      public void CallAttributeTester()
      {
          AttributeTester.CheckDefaultValues<DateTime>(new RequiredDateTimeRuleAttribute(), true, true, true);
          AttributeTester.CheckNonDefaultValues<DateTime>(new RequiredDateTimeRuleAttribute(), true, true, true);
      }

  }
}